class Solution
{
public:
    int minimumSwap(string s1, string s2)
    {
        if (s1.size() != s2.size())
        {
            return -1;
        }
        int xyCount = 0;
        int yxCount = 0;
        int n = s1.size();
        for (int i = 0; i < n; ++i)
        {
            if (s1[i] != s2[i])
            {
                if (s1[i] == 'x')
                {
                    ++xyCount;
                }
                else
                {
                    ++yxCount;
                }
            }
        }

        int result = xyCount / 2 + yxCount / 2;
        xyCount %= 2;
        yxCount %= 2;
        if (xyCount ^ yxCount)
        {
            return -1;
        }
        if (xyCount & yxCount)
        {
            result += 2;
        }
        return result;
    }
};